package com.hxd.oss;

import com.hxd.common.constant.Constants;
import com.hxd.common.core.spring.SpringContextHolder;
import com.hxd.oss.config.CloudStorageConfig;
import com.hxd.service.SysConfigService;

public class OSSFactory {

	private static SysConfigService sysConfigService;
	
	static {
		OSSFactory.sysConfigService = SpringContextHolder.getBean(SysConfigService.class);
	}

	public static CloudStorageService build() {
		
		CloudStorageConfig config = sysConfigService.getConfigObject("oss.config", CloudStorageConfig.class);
		
		if (config != null) {
			if (config.getType() == Constants.CloudService.LOCAL.getValue()) {
				return new LocalCloudStorageService(config);
			}
		}
		return null;
	}

}
